{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport DatePanel from \"../DatePanel\";\nimport TimePanel from \"../TimePanel\";\nimport { tuple } from \"../../utils/miscUtil\";\nimport { setDateTime as setTime } from \"../../utils/timeUtil\";\nvar ACTIVE_PANEL = tuple('date', 'time');\nfunction DatetimePanel(props) {\n  var prefixCls = props.prefixCls,\n    operationRef = props.operationRef,\n    generateConfig = props.generateConfig,\n    value = props.value,\n    defaultValue = props.defaultValue,\n    disabledTime = props.disabledTime,\n    showTime = props.showTime,\n    onSelect = props.onSelect;\n  var panelPrefixCls = \"\".concat(prefixCls, \"-datetime-panel\");\n  var _React$useState = React.useState(null),\n    _React$useState2 = _slicedToArray(_React$useState, 2),\n    activePanel = _React$useState2[0],\n    setActivePanel = _React$useState2[1];\n  var dateOperationRef = React.useRef({});\n  var timeOperationRef = React.useRef({});\n  var timeProps = _typeof(showTime) === 'object' ? _objectSpread({}, showTime) : {}; // ======================= Keyboard =======================\n\n  function getNextActive(offset) {\n    var activeIndex = ACTIVE_PANEL.indexOf(activePanel) + offset;\n    var nextActivePanel = ACTIVE_PANEL[activeIndex] || null;\n    return nextActivePanel;\n  }\n  var onBlur = function onBlur(e) {\n    if (timeOperationRef.current.onBlur) {\n      timeOperationRef.current.onBlur(e);\n    }\n    setActivePanel(null);\n  };\n  operationRef.current = {\n    onKeyDown: function onKeyDown(event) {\n      // Switch active panel\n      if (event.which === KeyCode.TAB) {\n        var nextActivePanel = getNextActive(event.shiftKey ? -1 : 1);\n        setActivePanel(nextActivePanel);\n        if (nextActivePanel) {\n          event.preventDefault();\n        }\n        return true;\n      } // Operate on current active panel\n\n      if (activePanel) {\n        var ref = activePanel === 'date' ? dateOperationRef : timeOperationRef;\n        if (ref.current && ref.current.onKeyDown) {\n          ref.current.onKeyDown(event);\n        }\n        return true;\n      } // Switch first active panel if operate without panel\n\n      if ([KeyCode.LEFT, KeyCode.RIGHT, KeyCode.UP, KeyCode.DOWN].includes(event.which)) {\n        setActivePanel('date');\n        return true;\n      }\n      return false;\n    },\n    onBlur: onBlur,\n    onClose: onBlur\n  }; // ======================== Events ========================\n\n  var onInternalSelect = function onInternalSelect(date, source) {\n    var selectedDate = date;\n    if (source === 'date' && !value && timeProps.defaultValue) {\n      // Date with time defaultValue\n      selectedDate = generateConfig.setHour(selectedDate, generateConfig.getHour(timeProps.defaultValue));\n      selectedDate = generateConfig.setMinute(selectedDate, generateConfig.getMinute(timeProps.defaultValue));\n      selectedDate = generateConfig.setSecond(selectedDate, generateConfig.getSecond(timeProps.defaultValue));\n    } else if (source === 'time' && !value && defaultValue) {\n      selectedDate = generateConfig.setYear(selectedDate, generateConfig.getYear(defaultValue));\n      selectedDate = generateConfig.setMonth(selectedDate, generateConfig.getMonth(defaultValue));\n      selectedDate = generateConfig.setDate(selectedDate, generateConfig.getDate(defaultValue));\n    }\n    if (onSelect) {\n      onSelect(selectedDate, 'mouse');\n    }\n  }; // ======================== Render ========================\n\n  var disabledTimes = disabledTime ? disabledTime(value || null) : {};\n  return /*#__PURE__*/React.createElement(\"div\", {\n    className: classNames(panelPrefixCls, _defineProperty({}, \"\".concat(panelPrefixCls, \"-active\"), activePanel))\n  }, /*#__PURE__*/React.createElement(DatePanel, _extends({}, props, {\n    operationRef: dateOperationRef,\n    active: activePanel === 'date',\n    onSelect: function onSelect(date) {\n      onInternalSelect(setTime(generateConfig, date, !value && _typeof(showTime) === 'object' ? showTime.defaultValue : null), 'date');\n    }\n  })), /*#__PURE__*/React.createElement(TimePanel, _extends({}, props, {\n    format: undefined\n  }, timeProps, disabledTimes, {\n    disabledTime: null,\n    defaultValue: undefined,\n    operationRef: timeOperationRef,\n    active: activePanel === 'time',\n    onSelect: function onSelect(date) {\n      onInternalSelect(date, 'time');\n    }\n  })));\n}\nexport default DatetimePanel;","map":{"version":3,"names":["_extends","_defineProperty","_objectSpread","_typeof","_slicedToArray","React","classNames","KeyCode","DatePanel","TimePanel","tuple","setDateTime","setTime","ACTIVE_PANEL","DatetimePanel","props","prefixCls","operationRef","generateConfig","value","defaultValue","disabledTime","showTime","onSelect","panelPrefixCls","concat","_React$useState","useState","_React$useState2","activePanel","setActivePanel","dateOperationRef","useRef","timeOperationRef","timeProps","getNextActive","offset","activeIndex","indexOf","nextActivePanel","onBlur","e","current","onKeyDown","event","which","TAB","shiftKey","preventDefault","ref","LEFT","RIGHT","UP","DOWN","includes","onClose","onInternalSelect","date","source","selectedDate","setHour","getHour","setMinute","getMinute","setSecond","getSecond","setYear","getYear","setMonth","getMonth","setDate","getDate","disabledTimes","createElement","className","active","format","undefined"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-picker/es/panels/DatetimePanel/index.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport DatePanel from \"../DatePanel\";\nimport TimePanel from \"../TimePanel\";\nimport { tuple } from \"../../utils/miscUtil\";\nimport { setDateTime as setTime } from \"../../utils/timeUtil\";\nvar ACTIVE_PANEL = tuple('date', 'time');\n\nfunction DatetimePanel(props) {\n  var prefixCls = props.prefixCls,\n      operationRef = props.operationRef,\n      generateConfig = props.generateConfig,\n      value = props.value,\n      defaultValue = props.defaultValue,\n      disabledTime = props.disabledTime,\n      showTime = props.showTime,\n      onSelect = props.onSelect;\n  var panelPrefixCls = \"\".concat(prefixCls, \"-datetime-panel\");\n\n  var _React$useState = React.useState(null),\n      _React$useState2 = _slicedToArray(_React$useState, 2),\n      activePanel = _React$useState2[0],\n      setActivePanel = _React$useState2[1];\n\n  var dateOperationRef = React.useRef({});\n  var timeOperationRef = React.useRef({});\n  var timeProps = _typeof(showTime) === 'object' ? _objectSpread({}, showTime) : {}; // ======================= Keyboard =======================\n\n  function getNextActive(offset) {\n    var activeIndex = ACTIVE_PANEL.indexOf(activePanel) + offset;\n    var nextActivePanel = ACTIVE_PANEL[activeIndex] || null;\n    return nextActivePanel;\n  }\n\n  var onBlur = function onBlur(e) {\n    if (timeOperationRef.current.onBlur) {\n      timeOperationRef.current.onBlur(e);\n    }\n\n    setActivePanel(null);\n  };\n\n  operationRef.current = {\n    onKeyDown: function onKeyDown(event) {\n      // Switch active panel\n      if (event.which === KeyCode.TAB) {\n        var nextActivePanel = getNextActive(event.shiftKey ? -1 : 1);\n        setActivePanel(nextActivePanel);\n\n        if (nextActivePanel) {\n          event.preventDefault();\n        }\n\n        return true;\n      } // Operate on current active panel\n\n\n      if (activePanel) {\n        var ref = activePanel === 'date' ? dateOperationRef : timeOperationRef;\n\n        if (ref.current && ref.current.onKeyDown) {\n          ref.current.onKeyDown(event);\n        }\n\n        return true;\n      } // Switch first active panel if operate without panel\n\n\n      if ([KeyCode.LEFT, KeyCode.RIGHT, KeyCode.UP, KeyCode.DOWN].includes(event.which)) {\n        setActivePanel('date');\n        return true;\n      }\n\n      return false;\n    },\n    onBlur: onBlur,\n    onClose: onBlur\n  }; // ======================== Events ========================\n\n  var onInternalSelect = function onInternalSelect(date, source) {\n    var selectedDate = date;\n\n    if (source === 'date' && !value && timeProps.defaultValue) {\n      // Date with time defaultValue\n      selectedDate = generateConfig.setHour(selectedDate, generateConfig.getHour(timeProps.defaultValue));\n      selectedDate = generateConfig.setMinute(selectedDate, generateConfig.getMinute(timeProps.defaultValue));\n      selectedDate = generateConfig.setSecond(selectedDate, generateConfig.getSecond(timeProps.defaultValue));\n    } else if (source === 'time' && !value && defaultValue) {\n      selectedDate = generateConfig.setYear(selectedDate, generateConfig.getYear(defaultValue));\n      selectedDate = generateConfig.setMonth(selectedDate, generateConfig.getMonth(defaultValue));\n      selectedDate = generateConfig.setDate(selectedDate, generateConfig.getDate(defaultValue));\n    }\n\n    if (onSelect) {\n      onSelect(selectedDate, 'mouse');\n    }\n  }; // ======================== Render ========================\n\n\n  var disabledTimes = disabledTime ? disabledTime(value || null) : {};\n  return /*#__PURE__*/React.createElement(\"div\", {\n    className: classNames(panelPrefixCls, _defineProperty({}, \"\".concat(panelPrefixCls, \"-active\"), activePanel))\n  }, /*#__PURE__*/React.createElement(DatePanel, _extends({}, props, {\n    operationRef: dateOperationRef,\n    active: activePanel === 'date',\n    onSelect: function onSelect(date) {\n      onInternalSelect(setTime(generateConfig, date, !value && _typeof(showTime) === 'object' ? showTime.defaultValue : null), 'date');\n    }\n  })), /*#__PURE__*/React.createElement(TimePanel, _extends({}, props, {\n    format: undefined\n  }, timeProps, disabledTimes, {\n    disabledTime: null,\n    defaultValue: undefined,\n    operationRef: timeOperationRef,\n    active: activePanel === 'time',\n    onSelect: function onSelect(date) {\n      onInternalSelect(date, 'time');\n    }\n  })));\n}\n\nexport default DatetimePanel;"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,eAAe,MAAM,2CAA2C;AACvE,OAAOC,aAAa,MAAM,0CAA0C;AACpE,OAAOC,OAAO,MAAM,mCAAmC;AACvD,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,SAAS,MAAM,cAAc;AACpC,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SAASC,WAAW,IAAIC,OAAO,QAAQ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